package cn.westv.scps.service.sysmsg.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.codehaus.jackson.map.deser.ValueInstantiators.Base;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import cn.westv.scps.dao.BaseDao;
import cn.westv.scps.domain.SysMessageEntity;
import cn.westv.scps.service.sysmsg.ISysMsgService;
import cn.westv.scps.utils.Page;

@Service
@Transactional
public class SysMsgServiceImpl implements ISysMsgService {

	@Autowired
	@Qualifier("baseDao")
	private BaseDao dao;

	@Override
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public List<SysMessageEntity> find(String hql, Class<SysMessageEntity> sysMessageEntity, Object[] params) {
		return dao.find(hql, sysMessageEntity, params);
	}

	@Override
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public SysMessageEntity get(Class<SysMessageEntity> sysMessageEntity, Serializable id) {
		return dao.get(sysMessageEntity, id);
	}

	@Override
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public Page<SysMessageEntity> findPage(String hql, Page<SysMessageEntity> page,
			Class<SysMessageEntity> sysMessageEntity, Object[] params) {
		return dao.findPage(hql, page, sysMessageEntity, params);
	}

	@Override
	@Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
	public void saveOrUpdate(SysMessageEntity entity) {
		dao.saveOrUpdate(entity);
	}

	@Override
	@Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
	public void save(SysMessageEntity entity) {
		dao.save(entity);
	}

	@Override
	@Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
	public void update(SysMessageEntity entity) {
		dao.update(entity);
	}

	@Override
	@Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
	public void saveOrUpdateAll(Collection<SysMessageEntity> entitys) {
		dao.saveOrUpdateAll(entitys);
	}

	@Override
	@Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
	public void deleteById(Class<SysMessageEntity> sysMessageEntity, Serializable id) {
		dao.deleteById(sysMessageEntity, id);
	}

	@Override
	@Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
	public void delete(Class<SysMessageEntity> sysMessageEntity, Serializable[] ids) {
		dao.delete(sysMessageEntity, ids);
	}

	@Override
	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public List<SysMessageEntity> querySQL(String SQL, Object[] params, Class<SysMessageEntity> sysMessageEntity) {
		return dao.querySQL(SQL, params, sysMessageEntity);
	}

	@Override
	public SysMessageEntity findByCode(String code) {
		List<SysMessageEntity> find = dao.find("from SysMessageEntity where code = ?", SysMessageEntity.class,
				new Object[] { code });
		if (find != null && find.size() > 0)
			return find.get(0);
		return null;
	}

}
